<?php

namespace App\Repository\Models;


use Illuminate\Database\Eloquent\Model;

class RoleUser extends Model 
{
    /**
     * 限制读取字段
     *
     * @var array
     */
    protected $guarded = [];

    public    $timestamps = false;
    protected $hidden = ['pivot'];
    /**
     * 设置模型表名
     *
     * @var string
     */
    protected $table = "role_user";

    static function multiCreate($params,$user_id){

        if (isset($params)){
            foreach ($params as $key=>$value){
                $tempCreate = [];
                $tempCreate = [
                    'user_id'=>$user_id,
                    'role_id'=>$value,
                ];
                $save = self::create($tempCreate);
            }
        }
        return true;
    }
}
